<template>
 <div>
   <el-form :inline="true" :model="queryForm" class="demo-form-inline">
     <el-form-item label="用户名">
       <el-input v-model="queryForm.username" placeholder="用户名"></el-input>
     </el-form-item>
     <el-form-item label="开始日期">
       <el-date-picker
           v-model="queryForm.rq1"
           type="date"
           placeholder="选择日期">
       </el-date-picker>
     </el-form-item>
     <el-form-item label="结束日期">
       <el-date-picker
           v-model="queryForm.rq2"
           type="date"
           placeholder="选择日期">
       </el-date-picker>
     </el-form-item>

     <el-form-item>
       <el-button type="primary" @click="list">查询</el-button>
     </el-form-item>
   </el-form>

     <el-table
         :data="tableData"
         style="width: 100%">
       <el-table-column
           prop="id"
           label="id"
           width="180">
       </el-table-column>
       <el-table-column
           prop="username"
           label="姓名"
           width="180">
       </el-table-column>

       <el-table-column
           prop="birthday"
           label="生日">
       </el-table-column>
       <el-table-column
         prop="header"
         label="头像">
         <template v-slot="scope">
           <el-image
               style="width: 100px; height: 100px"
               :src="scope.row.header"
               :fit="fit"></el-image>
         </template>
     </el-table-column>

     </el-table>
     <el-pagination

         @current-change="goPage"
         :page-size="size"
         layout="total, prev, pager, next"
         :total="total">
     </el-pagination>

 </div>
</template>

<script>
export default {
  name: "UserView",
  data() {
    return {
      tableData:[],
      queryForm:{

      },
      size:3,
      current:1,
      total:0,
    }
  }, methods: {
    goPage(page){
      this.current = page;
      this.list();
    },
     list(){
       this.axios.post("http://localhost:9999/user/list?current="+this.current+"&size="+this.size,this.queryForm).then(res=>{
         if(res.data.code==200){
           this.tableData= res.data.data.list;
           this.total =res.data.data.total;
         }else{
           this.$message.error(res.data.msg);
         }

       })
     }
  },
    created() {
      this.list();
  }
}
</script>

<style scoped>

</style>